/*
 * main.c
 *
 *  Created on: Nov 17, 2016
 *      Author: swolice
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char **argv) {
	char *path="dangdangwang.txt";
	char *respath="result.txt";
	FILE *pf;
	FILE *fp;
	pf=fopen(path, "r");
	fp=fopen(respath, "w");

	if (pf==NULL) {
		printf("file open failed.");
	} else {
		fseek(pf, 0, SEEK_END);
		int num=ftell(pf);
		char strinfo[2048];
		sprintf(strinfo, "\nnum=%d byte, %fK, %fM", num, num/1024.0, num/1024.0/1024.0);
		fputs(strinfo, fp);
		rewind(pf);

		while(!feof(pf))
		{
			char str[2048];
			fgets(str, 200, pf);
			if (strstr(str, "税廷")!=NULL) {
				fputs(str, fp);
				printf("\n%s", str);
			}
		}
		fclose(fp);
		fclose(pf);
	}
	system(respath);

	return EXIT_SUCCESS;
}




